package org.blogwu.learn.designpattern.chapter9.v2;

public class Test {
    public static void main(String[] args) throws CloneNotSupportedException {
        Mail mail = new Mail();
        mail.setContent("初始化模块");
        System.out.println(mail.hashCode());
        for (int i = 0; i < 10; i++) {
            Mail mailTemp = (Mail) mail.clone();
            System.out.println(mailTemp.hashCode());
            mailTemp.setName("姓名" + i);
            mailTemp.setEmailAddress("姓名" + i + "@imooc.com");
            mailTemp.setContent("恭喜你，怀孕了");
            MailUtil.sendMail(mailTemp);
        }
        //这儿的初始化模板已经变了
        MailUtil.saveOriginMailRecord(mail);

//        ThreadLocal tl=ThreadLocal.withInitial(()->23);
        ThreadLocal tl = ThreadLocal.withInitial(() -> {
            return 23;
        });
    }
}
